package com.changgou.goods.feign;

import com.changgou.entity.Result;
import com.changgou.goods.pojo.Sku;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

//定义skuFeign
@FeignClient(name = "goods")//表示远程调用的服务名称
public interface SkuFeign {
    //调用skuController中的结果
    @GetMapping("/sku/spu/{spuId}")
    public List<Sku> findSkuListBySpuId(@PathVariable("spuId") String spuId);

    //根据id查询sku信息
    @GetMapping("/sku/{id}")
    public Result<Sku> findById(@PathVariable("id") String id);

    //库存递减
    @PostMapping(value = "/sku/decr/count")
    Result decrCount(@RequestParam(value = "username") String username);

    //库存恢复
    @PostMapping("/sku/decr/resumeStockNum")
    void resumeStockNum(@RequestParam("skuId") String skuId,@RequestParam("num") Integer num);
}
